/**
 * 邮箱
 * @param {*} s
 */
export function isEmail(s) {
    return /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$/.test(s);
}

/**
 * 手机号码
 * @param {*} s
 */
export function isMobile(s) {
    return /^1[0-9]{10}$/.test(s);
}

/**
 * 电话号码
 * @param {*} s
 */
export function isPhone(s) {
    return /^([0-9]{3,4}-)?[0-9]{7,8}$/.test(s);
}

/**
 * URL地址
 * @param {*} s
 */
export function isURL(s) {
    return /^http[s]?:\/\/.*/.test(s);
}

/**
 * 匹配数字，可以是小数，不可以是负数,可以为空
 * @param {*} s
 */
export function isNumber(s) {
    return /(^-?[+-]?([0-9]*\.?[0-9]+|[0-9]+\.?[0-9]*)([eE][+-]?[0-9]+)?$)|(^$)/.test(s);
}
/**
 * 匹配整数，可以为空
 * @param {*} s
 */
export function isIntNumer(s) {
    return /(^-?\d+$)|(^$)/.test(s);
}
/**
 * 身份证校验
 */
export function checkIdCard(idcard) {
    const regIdCard = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
    if (!regIdCard.test(idcard)) {
        return false;
    } else {
        return true;
    }
}

export const rules = {
    username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
    // ---------------------------------------------------------------
    mima: [{ required: true, message: '请输入密码', trigger: 'blur' }],
    mima2: [
        {
            required: true,
            validator: (rule, value, callback) => {
                if (value === '') {
                    callback(new Error('请再次输入密码'));
                } else if (value !== this.ruleForm.mima) {
                    callback(new Error('两次输入密码不一致!'));
                } else {
                    callback();
                }
            },
            trigger: 'blur',
        },
    ],
    lianxidianhua: [{ required: true, message: '请输入联系电话', trigger: 'blur' }],
    // ---------------------------------------------------------------
    yihugonghao: [{ required: true, message: '请输入医护工号', trigger: 'blur' }],
    yihuxingming: [{ required: true, message: '请输入医护姓名', trigger: 'blur' }],
    yihuxingbie: [{ required: true, message: '请输入医护性别', trigger: 'blur' }],
    zhaopian: [{ required: true, message: '请输入照片', trigger: 'blur' }],
    zhicheng: [{ required: true, message: '请输入职称', trigger: 'blur' }],
    yihudengji: [{ required: true, message: '请输入医护等级', trigger: 'blur' }],
    shenfenzheng: [{ required: true, message: '请输入身份证', trigger: 'blur' }],
    // ---------------------------------------------------------------
    laorenbianhao: [{ required: true, message: '请输入老人编号', trigger: 'blur' }],
    laorenxingming: [{ required: true, message: '请输入老人姓名', trigger: 'blur' }],
    laorenzhaopian: [{ required: true, message: '请上传老人照片', trigger: 'change' }],
    laorenxingbie: [{ required: true, message: '请选择老人性别', trigger: 'blur' }],
    laorennianling: [{ required: true, message: '请输入老人年龄', trigger: 'blur' }],
    jiashuxingming: [{ required: true, message: '请输入家属姓名', trigger: 'blur' }],
    guanxi: [{ required: true, message: '请输入与老人关系', trigger: 'blur' }],
    shoujihao: [{ required: true, message: '请输入手机号', trigger: 'blur' }],
    jiatingzhuzhi: [{ required: true, message: '请输入家庭住址', trigger: 'blur' }],
};
